#include "Database.h"

Database* Database::_instance = 0;
int Database::_refCount = 0;

Database::Database(void)
{
	mesh = NULL;
	lsMesh2D = NULL;
}

Database* Database::getInstance()
{
	if(_instance==0)
		_instance = new Database();
	_refCount++; //increase reference counter
	return _instance;
}

void Database::Release()
{
	if( --_refCount < 1 )
	{
		Destroy();
	}
}

void Database::Destroy()
{
	if( _instance != 0 )
	{
		delete( _instance );
		_instance = 0;
	}
}

Database::~Database(void)
{
	broken_edges.clear();
	group_broken_edges.clear();
	cdt.clear();
	delete( mesh );
	delete( lsMesh2D );
}